#ifndef _THREAD_LIST_H_
#define _THREAD_LIST_H_

#include "user_threads.h"
#include <setjmp.h>

typedef struct node_s {
	void* entry;
	struct node_s *next;
	struct node_s *prev;
} node;
struct thread_list_s {
	node dummy; 
	unsigned int size;
};
typedef struct thread_list_s thread_list;

#define thread_list_for_each(list, curr) \
        for((curr) = thread_list_head(list); (curr) != NULL; (curr) = (curr)->next)

thread_list* thread_list_create();
int thread_list_destroy(thread_list* list);
int thread_list_insert_head(thread_list* list, void* entry);
int thread_list_insert_tail(thread_list* list, void* entry);
node* thread_list_insert_after(thread_list* list, node* n, void* entry);
void* thread_list_remove_head(thread_list* list);
//void* thread_list_remove_tail(thread_list* list);
void* thread_list_remove(thread_list* list, void* entry);
//void* thread_list_remove_after(thread_list *list, node* n);
void* thread_list_remove_node(thread_list *list, node* n);
node* thread_list_head(thread_list* list);
node* thread_list_tail(thread_list* list);
int thread_list_size(thread_list* list);
int thread_list_is_in(thread_list* list, void* entry);
int thread_list_is_empty(thread_list* list);
node* thread_list_find(thread_list* list, void* entry);
#endif /* _THREAD_LIST_H_ */
